/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.playground.client.websockets.application;

import com.playground.core.entity.Invitation;
import com.playground.core.repository.InvitationRepository;
import java.util.List;

/**
 *
 * @author Tiago Peres
 */
@Deprecated
public final class InvitationObserver extends Thread {
    private static final InvitationObserver INSTANCE = new InvitationObserver();
    private InvitationRepository invitationRepository;
    private boolean running;
    
    private InvitationObserver(){
        running = false;
    }
    
    @Override
    public void run() {
        running = true;
        while(true){
            List<Invitation> invitations = invitationRepository.findAll();
            // iterate invitations
            // if invitation.status = answered and all answers = yes: call queueService.queue(inviter + invited, invitation.gameTitle). Remove the invitation.
            // else if (invitation.status = answerTimeExpired) or (invitation.status = answered) : sends a message to the host (inviter) saying who accepted the invitation and asking if he wants to queue. Call invitationService.waitForHostConfirmation(invitation).
            // else if invitation.status = cancelled. Send a message to every guest and the host notifying about the cancelation.
            // Wait x seconds
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }

    public boolean isRunning() {
        return running;
    }
    
    public static InvitationObserver getInstance() {
        return INSTANCE;
    }
}
